/**
 * Created by root on 17-7-30.
 */

var index = require('../index');

module.exports = {

    queryDB : async function (callback) {
        try {

            //获取数据源
            var dbPool = index.getDB();

            dbPool.getConnection(function(err, connection) {
                // Use the connection
                connection.query('SELECT 1', [], function (error, results, fields) {
                    // And done with the connection.
                    connection.release();

                    // Handle error after the release.
                    if (error) throw error;

                    // Don't use the connection here, it has been returned to the pool.
                    console.log(results);
                    callback(results);

                    return new Promise(function (resolve, reject) {
                        resolve(results);
                    });
                });
            });

        } catch (e) {
            console.log(e);
        }
    }

};

